package com.assignwork.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import org.springblade.core.tool.utils.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springblade.core.tool.utils.Func;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * StartedCabinVO
 */
@Data
@ApiModel(value = "StartedCabinVO对象", description = "作业舱")
public class StartedCabinVO {

    /** 主键id;主键id */
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "主键id")
    private Long id;
    
    /** 创建时间 */
    @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;
    
    /** 更新时间 */
    @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
    @ApiModelProperty(value = "更新时间")
    private LocalDateTime updateTime;
    
    /** 舱名key */
    @ApiModelProperty(value = "舱名key")
    private String cabin;
    private String cabinName;

    private String hatch;
    private String hatchName;

    private String cabinAndHatch;
    private String cabinAndHatchName;

    /** 门机数量 */
    private Integer portalCraneCount;
    /** 辅助机械数量 */
    private Integer accessoryMachineryCount;
    /** 船机数量 */
    private Integer shipMachineryCount;

    /** 作业线ID */
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "作业线ID")
    private Long lineId;
    
    /** 门机序号 */
    @ApiModelProperty(value = "门机序号")
    private String portalCraneNo;
    
    /** 计划ID */
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "计划ID")
    private Long planId;
    
    /** 是否为实际作业 */
    @ApiModelProperty(value = "是否为实际作业")
    private Integer isReal;
    
    /** 总吨 */
    @ApiModelProperty(value = "总吨")
    private BigDecimal totalTon;
    
    /** 余吨 */
    @ApiModelProperty(value = "余吨")
    private BigDecimal remanentTon;
    
    /** 理货吨 */
    @ApiModelProperty(value = "理货吨")
    private BigDecimal tallyTon;
    
    /** 最终吨 */
    @ApiModelProperty(value = "最终吨")
    private BigDecimal settlementTon;
    
    /** 班次吨 */
    @ApiModelProperty(value = "班次吨")
    private BigDecimal shiftTon;
    
    /** 计划吨 */
    @ApiModelProperty(value = "计划吨")
    private BigDecimal planTon = BigDecimal.ZERO;

    private BigDecimal workTon = BigDecimal.ZERO;

    private String groupFg;

    private Integer cabinOrder = 0;

    public char getGroupIndex() {
        if (Func.isNotBlank(groupFg)) {
            return groupFg.charAt(0);
        }
        return 0;
    }

    public String getPlanTonStr() {
        if (planTon != null) {
            return planTon.stripTrailingZeros().toPlainString();
        }
        return "";
    }

    public String getWorkTonStr() {
        if (workTon != null) {
            return workTon.stripTrailingZeros().toPlainString();
        }
        return "";
    }

    //    public String getCabinName() {
//        if (Func.isNotBlank(cabin)) {
//            return cabin + "舱";
//        }
//        return cabinName;
//    }
}